package cn.oowoo.rabbitmq.limit;

import cn.oowoo.rabbitmq.config.RabbitConfig;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;
/**
 * @Author ZhangBin
 * @Date 2021/5/8 13:48
 * @Description: 消费端限流测试-生产者
 *
 **/

public class LimitProducer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitConfig.createConnection();
        // 创建消息通道
        Channel channel = connection.createChannel();

        for(int i=0;i<10;i++){
            String msg =  "一条限流消息...." + i;
            channel.basicPublish(RabbitConfig.EXCHANGE_LIMIT_NAME,RabbitConfig.ROUTING_PLIMIT_KEY, null, msg.getBytes());
        }
        channel.close();
        connection.close();
    }
}
